home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / programm.ing / ltmf_120.lzh / NICELINE.C < prev   
Encoding:
C/C++ Source or Header  |  1993-04-09  |  4.4 KB  |  173 lines

  1. /* ------------------------------------------------------------------------- */
  2. /* ----- Have a nice time with Niceline ------------------------------------ */
  3. /* ------------------------------------------------------------------------- */
  4. /* ----------------------------------------- (c) 1992 by Oliver Scheel ----- */
  5. /* --------------------------------------------- Freaky Deaky Software ----- */
  6. /* ------------------------------------------------------------------------- */
  7.  
  8. #include <portab.h>
  9. #ifdef STANDALONE
  10. #include <aes.h>
  11. #else
  12. #include <smallaes.h>
  13. #include <ltmf_str.h>
  14. #endif
  15. #include <vdi.h>
  16.  
  17. /* ------------------------------------------------------------------------- */
  18.  
  19. VOID save_regs _((VOID));
  20. VOID restore_regs _((VOID));
  21.  
  22. #ifndef STANDALONE
  23. EXTERN    LTMFLY    letemfly;
  24. #endif
  25.  
  26. /* ------------------------------------------------------------------------- */
  27.  
  28. #ifdef STANDALONE
  29. CHAR    *nclnwhat = { "@(#)Niceline Version 1.01     "__DATE__ };
  30. #endif
  31.  
  32. /* ------------------------------------------------------------------------- */
  33.  
  34. WORD    nl_handle = 1;
  35.  
  36. MLOCAL WORD STDARGS draw_line _((PARMBLK *p));
  37. MLOCAL WORD check_entry _((CHAR *s));
  38. MLOCAL WORD check_gfa _((OBJECT *tree));
  39.  
  40. VOID STDARGS init_niceline _((OBJECT *tree));
  41. /*
  42. USERBLK    niceline = {    draw_line,
  43.             0l };
  44. */
  45. USERBLK    niceline = {    draw_line,
  46.             (LONG)G_STRING };
  47.  
  48. /* ------------------------------------------------------------------------- */
  49. /* ----- draw niceline ----------------------------------------------------- */
  50. /* ------------------------------------------------------------------------- */
  51.  
  52. MLOCAL WORD STDARGS draw_line(p)
  53. PARMBLK    *p;
  54. {
  55.     WORD    pxyarray[4];
  56.     WORD    attrib[5];
  57.  
  58. /*    save_regs();
  59. */    vql_attributes(nl_handle, attrib);
  60.     vsl_type(nl_handle, 1);
  61.     vsl_width(nl_handle, 1);
  62.     vsl_color(nl_handle, BLACK);
  63.     pxyarray[0] = p->pb_x;
  64.     pxyarray[1] = pxyarray[3] = p->pb_y + p->pb_h/2 - 1;
  65.     pxyarray[2] = p->pb_x + p->pb_w;
  66.     vs_clip(nl_handle, 0, pxyarray);
  67.     v_pline(nl_handle, 2, pxyarray);
  68.     pxyarray[1]++;
  69.     pxyarray[3]++;
  70.     v_pline(nl_handle, 2, pxyarray);
  71.  
  72.     vsl_type(nl_handle, attrib[0]);
  73.     vsl_width(nl_handle, attrib[3]);
  74.     vsl_color(nl_handle, attrib[1]);
  75.  
  76. /*    restore_regs();    
  77. */    return(p->pb_currstate);
  78. }    
  79.  
  80. /* ------------------------------------------------------------------------- */
  81. /* ----- check_entry ------------------------------------------------------- */
  82. /* ------------------------------------------------------------------------- */
  83.  
  84. MLOCAL WORD check_entry(s)
  85. CHAR    *s;
  86. {
  87.     WORD    flag;
  88.  
  89.     if(*s)
  90.     {
  91.         flag = 0;
  92.         while((*s == '-') || (*s == '=') || (*s == ' '))
  93.         {
  94.             if(*s++ != ' ')
  95.                 flag = 1;
  96.         }
  97.         return(!*s && flag);
  98.     }
  99.     else
  100.         return(0);
  101. }
  102.  
  103. /* ------------------------------------------------------------------------- */
  104. /* ----- check_gfa --------------------------------------------------------- */
  105. /* ------------------------------------------------------------------------- */
  106.  
  107. MLOCAL WORD check_gfa(tree)
  108. OBJECT    *tree;
  109. {
  110.     WORD    i;
  111.     WORD    txt_cnt;
  112.  
  113.     txt_cnt = 0;
  114.     i = 0;
  115.     while((txt_cnt < 3) && !(tree[i].ob_flags & LASTOB))
  116.     {
  117.         if((tree[i].ob_type & 0xff) == G_STRING)
  118.             txt_cnt++;
  119.         i++;
  120.     }
  121.     return(tree[i-1].ob_spec.free_string[0] == ' ');
  122. }
  123.  
  124. /* ------------------------------------------------------------------------- */
  125. /* ----- init niceline ----------------------------------------------------- */
  126. /* ------------------------------------------------------------------------- */
  127.  
  128. VOID STDARGS init_niceline(tree)
  129. OBJECT    *tree;
  130. {
  131.     WORD    obj;
  132. /*    WORD    d;
  133. */    OBJECT    *tr;
  134.  
  135. #ifndef STANDALONE
  136.     if(!(letemfly.conf & C_NICELN))
  137.         return;
  138. #endif
  139. /*    nl_handle = graf_handle(&d, &d, &d, &d); */
  140.     obj = 0;
  141.     do
  142.     {
  143.         tr = &tree[obj];
  144.         if((tr->ob_state & DISABLED)
  145.             && ((tr->ob_type & 0xff) == G_STRING)
  146.             && check_entry(tr->ob_spec.free_string))
  147.         {
  148.             tr->ob_type &= 0xff00;
  149.             tr->ob_type |= G_USERDEF;
  150.             tr->ob_spec.userblk = &niceline;
  151.         }
  152.     }
  153.     while(!(tree[obj++].ob_flags & LASTOB));
  154. }
  155.  
  156. /* ------------------------------------------------------------------------- */
  157. /* ----- menu_patch -------------------------------------------------------- */
  158. /* ------------------------------------------------------------------------- */
  159.  
  160. VOID menu_patch(tree, showit)
  161. OBJECT    *tree;
  162. WORD    showit;
  163. {
  164. #ifndef STANDALONE
  165.     if(!(letemfly.conf & C_NICELN))
  166.         return;
  167. #endif
  168.     if((showit == 1) && check_gfa(tree))
  169.     {
  170.         init_niceline(tree);
  171.     }
  172. }
  173.